package com.zy.ivideo.controller;

import com.zy.ivideo.entity.BankCardEntity;
import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.entity.VersionEntity;
import com.zy.ivideo.entity.request.RequestVersionEntity;
import com.zy.ivideo.service.BankCardService;
import com.zy.ivideo.token.PassToken;
import com.zy.ivideo.token.UserToken;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/version")
@Api(value = "版本更新模块API接口", description = "该模块提版本在线升级模块服务", tags = "版本模块")
public class VersionController {


    /**
     * 版本更新
     * @param entity
     * @return
     */
    @PassToken
    @ApiOperation(value = "App在线升级", notes = "App在线升级", httpMethod = "POST")
    @PostMapping("/versionConfigurationUpdate")
    public ResponseEntity<VersionEntity> versionConfigurationUpdate(@RequestBody
                                                          @ApiParam(value = "版本实体类", name = "entity", required = true)
                                                                     RequestVersionEntity entity){
        ResponseEntity<VersionEntity> responseEntity = new ResponseEntity<>();

        VersionEntity versionEntity = new VersionEntity();

        if(entity.versionCode >= 6){//不需要更新
            versionEntity.update_url = "1";
            versionEntity.status = false;
            versionEntity.new_version = "6.0.0";
            versionEntity.updated_details = "";
            versionEntity.forced_updating = 1;
        }else{
            versionEntity.update_url = "1";
            versionEntity.status = true;
            versionEntity.new_version = "6.0.0";
            versionEntity.updated_details =  "1.修复已知BUG\n2.UI界面更新";
            versionEntity.forced_updating = 1;
        }
        responseEntity.setCode(0);
        responseEntity.setMsg("");
        responseEntity.setData(versionEntity);


        return responseEntity;
    }

}
